package com.maolong.springbootstartordercenter.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ReturnCallBack implements RabbitTemplate.ReturnCallback {
    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        log.info("消息发送失败,消息内容{},回复码{},回复信息{},交换机{},路由键{}",new String(message.getBody()),replyCode,replyText,exchange,routingKey);

        /**
         * 做其他操作，比如是否重新发送，
         * 失败信息写入数据库等等
         */
    }
}
